'use strict';

module.exports = appInfo => {
  const config = exports = {};

  // 设置 keys，用于加密 Cookie 和 Session
  config.keys = appInfo.name + '_real_estate_platform_2024';

  // 数据库配置
  config.mysql = {
    client: {
      host: 'localhost',
      port: '3306',
      user: 'appuser',
      password: 'root',
      database: 'real_estate_platform',
      acquireTimeout: 60000,
      timeout: 60000,
      reconnect: true,
      charset: 'utf8mb4',
    },
    app: true,
    agent: false,
  };

  // 跨域配置 - 修复403错误
  config.cors = {
    origin: '*', // 允许所有来源，开发环境可以这样设置
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
    allowHeaders: 'Content-Type,Authorization,X-Requested-With',
    credentials: true,
  };

  // 安全配置
  config.security = {
    csrf: {
      enable: false, // 开发环境关闭CSRF保护
    },
  };

  return config;
};